<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>吉车惠后台管理系统</title>
	<%@include file="/global/global-other.jsp" %>
	<script type="text/javascript">
	$(function() {

		submitForm = function($dialog){

			$('#sys_password_form').form('submit',{
				url:'${ctx}/system/main/updatePassword',
				queryParams:{_m:'exec'},
                onSubmit:function(){
                    if($(this).form('enableValidation').form('validate')){
						return true;
					}else{
						return false;
					}
                },
                success:function(data){
					var json =  eval("(" +data+ ")");
					if(statusMsg(json)){
						parent.$.messager.alert("提示","保存成功，请使用新密码登录！","info",function(){
							$dialog.dialog('destroy');
						});
					}
			    }
            });
		};
		
		$('#passwd').keyup(function () { 
			var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g"); 
			var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g"); 
			var enoughRegex = new RegExp("(?=.{6,}).*", "g"); 
		
			if (false == enoughRegex.test($(this).val())) { 
				$('#level').removeClass('pw-weak'); 
				$('#level').removeClass('pw-medium'); 
				$('#level').removeClass('pw-strong'); 
				$('#level').addClass(' pw-defule'); 
				//密码小于六位的时候，密码强度图片都为灰色 
				
			} 
			else if (strongRegex.test($(this).val())) { 
				$('#level').removeClass('pw-weak'); 
				$('#level').removeClass('pw-medium'); 
				$('#level').removeClass('pw-strong'); 
				$('#level').addClass(' pw-strong'); 
				//密码为八位及以上并且字母数字特殊字符三项都包括,强度最强 
				
			} 
			else if (mediumRegex.test($(this).val())) { 
				$('#level').removeClass('pw-weak'); 
				$('#level').removeClass('pw-medium'); 
				$('#level').removeClass('pw-strong'); 
				$('#level').addClass(' pw-medium'); 
				//密码为七位及以上并且字母、数字、特殊字符三项中有两项，强度是中等 
				
			} 
			else { 
				$('#level').removeClass('pw-weak'); 
				$('#level').removeClass('pw-medium'); 
				$('#level').removeClass('pw-strong'); 
				$('#level').addClass('pw-weak'); 
				//如果密码为6为及以下，就算字母、数字、特殊字符三项都包括，强度也是弱的 
				
			} 
			return true; 
		}); 
	});
</script>
	</head>
<body>
<div class="form-box">
	<div class="form-body">
		<form role="form" method="POST" name="sys_password_form" id="sys_password_form" class="easyui-form form form-horizontal" data-options="novalidate:true">
			<div class="seg-title">
				<div class="seg-title-box">
		    		 <ul>
			    		<li class="seg-title-box-icon" ><img src="${ctx }/assets/images/communication.gif"/></li>
			    		<li class="seg-title-box-text">基本信息</li>
			    	</ul>
		    	</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">
					<p class="label-txt">旧密码：</p>
					<p class="star">*</p>
				</label>
				<div class="col-sm-7">
					<input type="password" id="oldpasswd" name="oldpasswd" value="" class="form-control easyui-validatebox" style="width:100%;height:34px;line-height:34px;" title="旧密码" required="required" validType="length[6,20]" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label" >
					<p class="label-txt">新密码：</p>
					<p class="star">*</p>
				</label>
				<div class="col-sm-7">
					<input type="password" id="passwd" name="passwd" value="" class="form-control easyui-validatebox" style="width:100%;height:34px;line-height:34px;" title="新密码" data-options="required:true,validType:'length[6,20]'">
					<div id="level" class="pw-strength">           	
					<div class="pw-bar"></div>
						<div class="pw-bar-on"></div>
						<div class="pw-txt">
						<span>弱</span>
						<span>中</span>
						<span>强</span>
						</div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">
					<p class="label-txt">确认密码：</p>
					<p class="star">*</p>
				</label>
				<div class="col-sm-7">
					<input type="password" id="passwdre" name="passwdre" value="" class="form-control easyui-validatebox" style="width:100%;height:34px;line-height:34px;" title="确认密码" data-options="required:true" validType="equalTo['#passwd']">
				</div>
			</div>
		</form>
	</div>
</div>
</body>
</html>